package com.qf.shoppinguser.controller;


import com.qf.shoppinguser.entity.User;
import com.qf.shoppinguser.util.CacheManagerSevice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
public class BaseController {
    public User user;

    @Autowired
    CacheManagerSevice cacheManagerSevice;

    @ModelAttribute
    public void expireLogin(HttpServletRequest request, HttpServletResponse response) {
        System.out.println("查看用户token是否过期");
//        if (user == null) {
//            return;
//        }
        Object o = cacheManagerSevice.get(user.getPhone());
        if (o != null) {
            System.out.println("未过期");
        } else {
            response.setStatus(403);
        }

    }
}
